#define _CRT_SECURE_NO_WARNINGS 1
//#include <fstream>
//#include <iostream>
//#include <string>
//#include <sstream>
//#include<vector>
//#include<algorithm>
//using namespace std;
#include<stdio.h>
#include<string.h>
int lengthOfLastWord(char* s) {
    int len = strlen(s);
    int ans = 0;
    int flag = 0;
    for (int i = len-1; i >= 0; i--)
    {
        if (s[i] == ' ' && flag==1)
        {
            flag = 0;
            continue;
        }
        else if (s[i] != ' ')
        {
            ans++;
            flag = 2;
        }
        else if (s[i]==' ' && flag == 2)
        {
            break;
        }

    }
    return ans;
}
int main() {
    char s[] = { " hello world  " };
    printf("%d",lengthOfLastWord(s));
	return 0;
}